<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目申请记录</title>
<link type="text/css"
	href="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/themes/metro/easyui.css"
	rel="stylesheet" />
<link type="text/css"
	href="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/themes/mobile.css"
	rel="stylesheet" />
<link type="text/css"
	href="${pageContext.request.contextPath}/assets/css/common.css"
	rel="stylesheet" />
<style type="text/css">
.main {
	margin-right: 15px;
}

ul {
	list-style: none;
}

.icon-list li a {
	cursor: pointer;
}
</style>
</head>
<body>
	<div class="main">
		<!--工具栏-->
		<div id="floatHead" class="toolbar-wrap">
			<div class="toolbar">
				<div class="box-wrap">
					<a class="menu-btn"></a>
					<div class="l-list">
						<ul class="icon-list">
						          项目起始时间&nbsp;
							<input id="START_DATE" style="height:30px;" class="easyui-datebox" type="text" data-options="onSelect:onSelect"></input>&nbsp;至&nbsp;
							<input id="END_DATE" style="height:30px;" class="easyui-datebox" type="text" data-options="onSelect:onSelect"></input>
						</ul>
						<div class="menu-list">
							<div class="rule-single-select single-select">
								<div class="boxwrap">
									<a class="select-tit" href="javascript:;"> <span>所有项目</span>
										<i></i>
									</a>
									<div class="select-items" style="z-index: 1;">
										<ul>
											<li id="-1" class="selected">所有项目</li>
											<li id="0">已录入</li>
											<li id="1">待审核</li>
											<li id="2">已审核</li>
											<li id="3">已发布</li>
											<li id="4">已招满</li>
											<li id="5">已停用</li>
										</ul>
									</div>
									<i class="arrow" style="z-index: 1; display: none;"></i>
								</div>
							</div>
						</div>
					</div>
					<div class="r-list">
						<input id="search" class="keyword" /> <a href="javascript:void(0);" class="btn-search"
							onclick="searchItem()">查询</a>
					</div>
				</div>
			</div>
		</div>
		<!--/工具栏-->

		<table id="tt"></table>
	</div>

	<script
		src="${pageContext.request.contextPath}/assets/js/jquery-1.11.2.min.js"
		charset="utf-8" type="text/javascript"></script>
	<script
		src="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/jquery.easyui.min.js"
		charset="utf-8" type="text/javascript"></script>
	<script
		src="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"
		charset="utf-8" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/assets/js/common.js" 
		type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
	var contextPath = '<%=request.getContextPath()%>';
	$(function(){
		getTableList();
		$(window).resize(function() {
			//延迟执行,防止多次触发
			setTimeout(function() {
				$('#tt').datagrid('resize');
			}, 100);
		});
		//下拉框方法
		$('.select-tit i').click(function() {
			$('.boxwrap .select-items').css('display', 'block');
			$('.boxwrap .arrow').css('display', 'inline');
		})
		$(document).click(function(e) {
			var hasClass = $(e.target).parents().hasClass('boxwrap');
			if (!hasClass) {
				$('.boxwrap .select-items').css('display', 'none');
				$('.boxwrap .arrow').css('display', 'none');
			}
		})
		$('.select-items ul li').click(function() {
			$(this).parent().find('li').removeClass('selected');
			$(this).addClass('selected');
			$('.select-tit span').html($(this).html());
			$('.boxwrap .select-items').css('display', 'none');
			$('.boxwrap .arrow').css('display', 'none');
			getTableList();
		})
	})
	/*获取数据列表*/
	function getTableList() {
		var startDate=$("#START_DATE").datebox('getValue');
		var endDate=$("#END_DATE").datebox('getValue');
		if($.isNullOrEmpty(startDate)||$.isNullOrEmpty(endDate)){
			startDate='';
			endDate='';
		}
		var statusList = '0,1,2,3,4,5';
		var status_id = $('.select-items ul li.selected').attr('id');
		if (!$.isNullOrEmpty(status_id)) {
			if (status_id != '-1') {
				statusList = status_id;
			}
		}
		var search=$('#search').val();
		$('#tt').datagrid({
	        //height: $('body').height() - 270,
	        nowrap: true,
	        striped: true,
	        collapsible: false,
	        remoteSort: false,
	        selectOnCheck: false,
	        checkOnSelect: false,
	        singleSelect: true,
	        fitColumns: true,
	        url: contextPath + "/bg/IM111.do?item_status="+ statusList + "&search="+encodeURI(search)+"&startDate="+encodeURI(startDate)+"&endDate="+encodeURI(endDate)+"&rnd=" +Math.random(),
	        columns: [[
	            {
	                field: 'CODE',
	                title: '项目编码',
	                align: 'center',
	                width: 100
								},
	            {
	                field: 'NAME',
	                title: '项目名称',
	                align: 'center',
	                width: 100,
								},
	            {
	                field: 'PARENT_NAME',
	                title: '项目类别',
	                align: 'center',
	                width: 100
								},
	            {
	                field: 'START_DATE',
	                title: '起始时间',
	                align: 'center',
	                width: 100
								},
	            {
	                field: 'STATUS_NAME',
	                title: '项目状态',
	                align: 'center',
	                width: 100
								},
				{
					field: 'OTHER3',
					title: '项目查看',
					align: 'center',
					width: 100,
					formatter: function (id, row, index) {
						return '<button type="button" onclick="show(\'' +
							   row.CODE +
							'\')" class="btn">查看</button>';
					}
								},	
				{
					field: 'OTHER1',		
	                title: '受试者信息',
	                align: 'center',
	                width: 100,
	                formatter:function(id, row, index){
	                    return '<button type="button" onclick="view(\'' +
                        row.CODE +
                        '\')" class="btn">查看</button>';	                	
	                }
				}
								]],
	        pagination: true,
	        pageSize: 10,
	        pageList: [10, 15, 30, 40]
	    });		
	}
	//查询
	function searchItem(){
		var start_date=$("#START_DATE").datebox('getValue');
		var end_date=$("#END_DATE").datebox('getValue');
		var d1 = new Date(start_date.replace(/\-/g, "\/")); 
		var d2 = new Date(end_date.replace(/\-/g, "\/"));  
/* 		if(start_date!=""&&end_date!="") 
		{ 
			if(d1>d2){
				alert("开始时间不能大于结束时间！"); 
				return false; 
			}
			else{
				getTableList(start_date,end_date);
			}
		}else{
			getTableList('','');
		}	 */	
		if(d1>d2){
			alert("开始时间不能大于结束时间！"); 
			return false; 
		}
		getTableList();
	}
	//日期选中事件
	function onSelect(date){
		var start_date=$("#START_DATE").datebox('getValue');
		var end_date=$("#END_DATE").datebox('getValue');
		var d1 = new Date(start_date.replace(/\-/g, "\/")); 
		var d2 = new Date(end_date.replace(/\-/g, "\/"));  
		if(start_date!=""&&end_date!="") 
		{ 
			if(d1>d2){
	  			$.messager.show({title:'提示',msg:'开始时间不能大于结束时间！',showType:'slide'});
	  			$('#START_DATE').focus();
				return false; 
			}
			else{
				getTableList();
			}
		}
	}
	//申请人员查看
	function view(code){
		location.href=contextPath+"/bg/item_application_view.do?code="+code+"&rnd="+Math.random();
	}
	//项目查看
	function show(code){
		location.href = contextPath + "/bg/item_edit.do?action=edit&show=1&code="
		+ code + "&rnd=" + Math.random();
	}
	</script>
</body>
</html>